package data

import (
	"gitee.com/thingple/saturn/internal/communication"
	"github.com/lishimeng/app-starter"
	"github.com/lishimeng/app-starter/server"
	"net/http"
)

func restProxy(ctx server.Context) {

	var err error
	var req communication.RestJob
	var resp app.Response
	err = ctx.C.ReadJSON(&req)
	if err != nil {
		resp.Code = http.StatusBadRequest
		resp.Message = err.Error()
		ctx.Json(resp)
		return
	}

	var data map[string]any
	err = req.Fetch(&data)
	if err != nil {
		resp.Code = http.StatusBadRequest
		resp.Message = err.Error()
		ctx.Json(resp)
		return
	}
	ctx.Json(data)
}
